function renderHeader(value, cellmeta, record, rowIndex, columnIndex, store) {
	var fieldName = Ext.getCmp(querykey).getColumnModel()
			.getDataIndex(columnIndex);
	if (fieldName == 'STAMP_TYPE') {
		var resultString = '';

		if (value == '1') {
			resultString = '汽油93#';
		} else if (value == '2') {
			resultString = '汽油97#';
		} else if (value == '3') {
			resultString = '柴油';
		}

		return resultString;
	}
	return value;
}

/**
 * 更新成功后回调函数
 */
function forwardFunc() {
	window.location.href = context
			+ '/system/tablequery/jsplist.jsp?queryKey=sqyeslist';
}

/**
 * 初始化form表单项
 * 
 * @param {}
 *            json
 */
function initFunc(json) {
	if (json != null && json.success == true) {
		$('CARSQ_ID').value = json.data.CARSQ_ID;
		$('CARSQ_UNIT').value = json.data.CARSQ_UNIT;
		$('CARSQ_UNITID').value = json.data.CARSQ_UNITID;
		$('CARSQ_USER').value = json.data.CARSQ_USER;
		$('CARSQ_USERID').value = json.data.CARSQ_USERID;
		$('CARSQ_CL').value = json.data.CARSQ_CL;
		$('CARSQ_CLID').value = json.data.CARSQ_CLID;
		$('CARSQ_TEL').value = json.data.CARSQ_TEL;
		$('CARSQ_CCRW').value = json.data.CARSQ_CCRW;
		$('CARSQ_QXYT').value = json.data.CARSQ_QXYT;
		$('CARSQ_XSLC').value = json.data.CARSQ_XSLC;
		$('CARSQ_KSSJ').value = formatDate(json.data.CARSQ_KSSJ.substring(0, 8))
				+ ' '
				+ json.data.CARSQ_KSSJ.substring(8, 10)
				+ ':'
				+ json.data.CARSQ_KSSJ.substring(10, 12);
		$('CARSQ_JZSH').value = formatDate(json.data.CARSQ_JZSH.substring(0, 8))
				+ ' '
				+ json.data.CARSQ_JZSH.substring(8, 10)
				+ ':'
				+ json.data.CARSQ_JZSH.substring(10, 12);
		$('CARSQ_RS').value = json.data.CARSQ_RS;
		$('CARSQ_XZ').value = json.data.CARSQ_XZ;
		$('CARSQ_MEMO').value = json.data.CARSQ_MEMO;
		$('CARSQ_DJR').value = json.data.CARSQ_DJR;
		$('CARSQ_DJRID').value = json.data.CARSQ_DJRID;
		$('CARSQ_DATE').value = json.data.CARSQ_DATE;
		$('CARSQ_STATUS').value = json.data.CARSQ_STATUS;
		$('CARSQ_YY').value = json.data.CARSQ_YY;

	}
}

function checkit() {
	var rnt = true;

	if (!isinteger($('STAMP_ID'))) {
		rnt = false;
		alert('请选择油票');
	} else if (!isinteger($('STAMP_COUNT'))) {
		rnt = false;
		alert('请设置正确的油票数量');
	} else if($('STAMP_COUNT').value > $('STAMP_KC').value){
		rnt = false;
		alert('油票库存不足');	
	}

	return rnt;
}

/**
 * 审批通过
 */
function handleStemp() {
	var params = {};
	params.CARSQ_ID = $('CARSQ_ID').value;
	params.CARSQ_STATUS = '2';
	params.STAMP_ID = $('STAMP_ID').value;
	params.STAMP_NO = $('STAMP_NO').value;
	params.STAMP_COUNT = $('STAMP_COUNT').value;
	params.STAMP_KC = $('STAMP_KC').value - $('STAMP_COUNT').value;

	updateColumn('APP_CARSQ,APP_CARSTAMP', 'single,single', '1,1', params, function() {
				return checkit();
			}, function() {
				forwardFunc();
			});
}

function setStemp(record) {
	$('STAMP_ID').value = record.data.STAMP_ID;
	$('STAMP_NO').value = record.data.STAMP_NO;
	$('STAMP_KC').value = record.data.STAMP_KC;
}